window.onload = function  () {
	// 获取页面的元素
	img_list = document.getElementsByClassName('img_list');

	click_list =  document.getElementsByClassName('click_list');

	click_left = document.getElementById('click_left');

	click_right = document.getElementById('click_right');

	banner =  document.getElementById('banner');

	//初始位置
	num = 0;

	function run () {
		// 循环让所有图片消失
		for (var i = 0; i <img_list.length ; i++) {
			img_list[i].style.display="none";
			click_list[i].style.backgroundColor="#fff";
		};

		//其中某一张出现
		img_list[num].style.display="block";
		click_list[num].style.backgroundColor="red";

		//到达最后一张置为0，否则++
		if(num==(img_list.length-1)){
			num =0;
		}else{
			num++;
		}
	}

	// 定时器
	time = setInterval(run, 1000);


	// 大区域进去出来 
	banner.onmouseover = function  (argument) {
		clearInterval(time);
	}

	banner.onmouseout = function  (argument) {
		time = setInterval(run, 1000);
	}

	// 右点
	click_right.onclick = function  () {
		run();
	}

	// 循环加给加事件
	for (var i = 0; i < click_list.length; i++) {
		click_list[i].index=i
		click_list[i].onclick = function  (en) {
			console.log(this.index);
			num = this.index;
			run();
		}
		// add_click(i);
	};

	function add_click (i) {
		click_list[i].onclick = function  () {
			num = i;
			run();
		}
	}

	























}